package com.shrct.businessprocess.organization.impl;

import com.shrct.businessprocess.organization.RCEmployee;
import com.shrct.businessprocess.organization.RCEnterprise;
import com.shrct.businessprocess.organization.RCEnterpriseCriteria;
import edu.fudan.mylang.pf.query.HQLBasedPagedQueryCriteria;
import org.hibernate.Query;

public class RCEnterpriseCriteriaImpl extends HQLBasedPagedQueryCriteria<RCEnterprise> implements RCEnterpriseCriteria {
  private String info;
  
  public String getInfo() {
    return this.info;
  }
  
  public RCEnterpriseCriteria setInfo(final String info) {
    this.info = info;
    return this;			
    
  }
  
  private RCEmployee businessMan;
  
  public RCEmployee getBusinessMan() {
    return this.businessMan;
  }
  
  public RCEnterpriseCriteria setBusinessMan(final RCEmployee businessMan) {
    this.businessMan = businessMan;
    return this;			
    
  }
  
  protected String buildHQLFrom() {
    return " from com.shrct.businessprocess.organization.impl.RCEnterpriseImpl this ";
  }
  
  protected String buildHQLBody() {
    String hql = "where 1 = 1 ";
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getBusinessMan()) ){
    	hql += " and ((this.businessMan) = (:businessMan))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) && !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) && !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) && !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) && !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) && !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) && !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) && !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) && !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) && !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) && !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) && !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) && !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) && !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) && !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) ){
    	hql += " and (((((((((((((((this.code  LIKE :info) or (this.name  LIKE :info)) or (this.shortName  LIKE :info)) or (this.ename  LIKE :info)) or (this.spell  LIKE :info)) or (this.helpCode  LIKE :info)) or (this.enterpriseEnrolNum  LIKE :info)) or (this.workNo  LIKE :info)) or (this.legalPerson  LIKE :info)) or (this.aptitudeName  LIKE :info)) or (this.aptitudeNo  LIKE :info)) or (this.phone  LIKE :info)) or (this.email  LIKE :info)) or (this.address  LIKE :info)) or (this.simplePy  LIKE :info))" ;
    }
    return hql;
    
  }
  
  public void initOrderBys() {
    addOrder("this.code",edu.fudan.mylang.pf.query.OrderItem.ASC);
  }
  
  protected void fillParameter(final Query query) {
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo())){
    	query.setParameter("info",getInfo()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getBusinessMan())){
    	query.setParameter("businessMan",getBusinessMan()) ;
    }			
    
  }
  
  protected Boolean isDistinct() {
    return false;
  }
  
  public RCEnterpriseCriteriaImpl() {
    initOrderBys();
  }
}
